/*
 * @Descripttion: null
 * @Author: lcx
 * @version: v01
 * @Date: 2023-10-18 21:35:11
 * @LastEditors: lcx
 * @LastEditTime: 2023-10-18 22:01:16
 */

abstract class Handler {
    Handler handler;
    public abstract void  handleRequest(int request);
    public void setNext(Handler handler) {
        this.handler = handler;
    }

}

class Tetcher extends Handler {
    public void handleRequest(int request) {
        if (request <= 7)
            System.out.println("Tetcher approve: " + request + " days-off");
        else {
            if (handler != null)
                handler.handleRequest(request);
        }
    }
}


class Counsellor extends Handler {
    public void handleRequest(int request) {
        if (request <= 15)
            System.out.println(" Counsellor approve: " + request + " days-off");
        else {
            if (handler != null)
                handler.handleRequest(request);
        }
    }
}

class HeadMaster extends Handler {
    public void handleRequest(int request) {
        if (request <= 30)
            System.out.println(" HeadMaster approve: " + request + " days-off");
        else
        {
          System.out.println("denied request : " + request + " days-off");
        }
    }
}

class test {
    public static void main(String[] args) {
        Tetcher teacher = new Tetcher();
        Counsellor counsellor = new Counsellor();
        HeadMaster headMaster = new HeadMaster();

        teacher.setNext(counsellor);
        counsellor.setNext(headMaster);

        teacher.handleRequest(25);

    }
}